//
//  OPMoviePosterCCell.m
//  OnePerson
//
//  Created by xiaofulon on 16/6/12.
//  Copyright © 2016年 BWP. All rights reserved.
//

#import "OPMoviePosterCCell.h"
/**cell复用ID*/
NSString *const kMLBMoviePosterCCellID = @"kMLBMoviePosterCCellID";

@interface OPMoviePosterCCell ()
/**剧照View*/
@property (strong, nonatomic) UIImageView *posterView;

@end

@implementation OPMoviePosterCCell
// 重用时先清空image
- (void)prepareForReuse {
    _posterView.image = nil;
}
// 重写init,添加剧照view
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    
    if (self) {
        [self setupViews];
    }
    
    return self;
}

- (void)setupViews {
    // 懒加载
    if (_posterView) {
        return;
    }
    
    self.backgroundColor = [UIColor whiteColor];
    self.contentView.backgroundColor = [UIColor whiteColor];
    // 剧照imageview
    _posterView = ({
        UIImageView *imageView = [UIImageView new];
        // 设置图片为按比例填充
        imageView.contentMode = UIViewContentModeScaleAspectFill;
        // 超出部分剪切
        imageView.clipsToBounds = YES;
        // 添加到cell
        [self.contentView addSubview:imageView];
        // size和contentView一样
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        imageView;
    });
}

#pragma mark - Public Method
//给剧照模块设置图片
- (void)configureCellWithPostURL:(NSString *)posterURL {
    [_posterView mlb_sd_setImageWithURL:posterURL placeholderImageName:nil];
}

@end
